const ONLINE = 0;
const OFFLINE = 1;
import { getUserCouponList } from '../../services/user';

Page({
  data: {
    ONLINE,
    OFFLINE,
    tabs: [
      {
        id: 0,
        title: '全部',
        onClick: () => { },
      },
      {
        id: 1,
        title: '已领取',
        onClick: () => { },
      },
      {
        id: 2,
        title: '已使用',
        onClick: () => { },
      },
      {
        id: 3,
        title: '已过期',
        onClick: () => { },
      },
    ],
    tickets: [
      {
        id: 0,
        price: 30,
        baseline: 300,
        startAt: '2019.4.01',
        endAt: '2019.12.31',
        action: 0
      },
      {
        id: 0,
        price: 30,
        baseline: 300,
        startAt: '2019.4.01',
        endAt: '2019.12.31',
        action: 1
      },
      {
        id: 0,
        price: 30,
        baseline: 300,
        startAt: '2019.4.01',
        endAt: '2019.12.31',
        action: 2
      },
    ],
    activeId: 0,
  },
  onLoad() {
    my.setNavigationBar({
      title: '我的优惠券',
      backgroundColor: '#4BA3F9'
    })
  },
  getUserCouponList() {
    getUserCouponList({}).then(res => {
      if (res.code == "000000") {
        this.setData({ tickets: res.data })
      }
    })
  },
  onShow() {
    this.getUserCouponList()
  },
  onTabItemTap(id) {
    console.log(id);
    this.setData({ activeId: id });
  },
});
